home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / NGService / MMFolderCell.m < prev    next >
Encoding:
Text File  |  1992-08-10  |  1.3 KB  |  61 lines

  1. /*
  2.  *      You may freely copy, distribute and reuse the code
  3.  *      in this example.  Scott Anguish disclaims any warranty of
  4.  *      any kind, expressed or implied, as to its fitness
  5.  *      for any particular use.
  6.  *        Please keep this notice intact
  7.  *      Written by: Scott Anguish  sanguish@digifix.com
  8.  */
  9.  
  10. #import "MMFolderCell.h"
  11.  
  12. #import <libc.h>                      /* MAXPATHLEN */
  13. #import <stdio.h>
  14. #import <strings.h>
  15.  
  16. #import <appkit/appkit.h>
  17.  
  18. #import <streams/streams.h>
  19.  
  20.  
  21. @implementation MMFolderCell:MMCell
  22.  
  23. - imageFromFilename:(const char *)filename
  24. {
  25.     char    *tiff;
  26.     int     length;
  27.     int    okFlag;
  28.     NXStream *localStream;
  29.     id    speaker = [NXApp appSpeaker];
  30.     
  31.  
  32.     if (!theImage)
  33.             {
  34.             [speaker setSendPort: NXPortFromName(NX_WORKSPACEREQUEST, NULL)];
  35.             [speaker getFileIconFor:filename TIFF:&tiff TIFFLength:&length ok:&okFlag];
  36.             if (okFlag){ 
  37.                 localStream = NXOpenMemory(tiff, length, NX_READONLY);
  38.                 theImage = [[NXImage alloc] initFromStream: localStream ];
  39.                 NXCloseMemory(localStream, NX_FREEBUFFER);
  40.                 } else
  41.                     {
  42.                     theImage = [[NXImage alloc] 
  43.                     initFromFile: "/usr/lib/nib/folder_nib.tiff" ];
  44.                     }
  45.             }    return self;
  46.  
  47. }    
  48.  
  49. - imageFromAttachment
  50. {
  51.  
  52.     char filename[MAXPATHLEN+1];
  53.  
  54.     sprintf(filename,"/tmp/%s",attachmentName);
  55.     [self imageFromFilename:filename];
  56.     return self;
  57. }
  58.  
  59.  
  60. @end
  61.